package com.zyg.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.zyg.pojo.Class;
import com.zyg.pojo.Grade;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface ClassMapper extends BaseMapper<Class> {
    @Override
    @Select("select * from sys_class ${ew.customSqlSegment}")
    @Results(id="classMap",value = {
            @Result(column = "class_id",property = "classId"),
            @Result(column = "class_name",property = "className"),
            @Result(column = "grade_id",property = "grade",javaType = Grade.class,
                    one = @One(select = "com.zyg.dao.GradeMapper.selectById",fetchType = FetchType.EAGER)),
    })
    List<Class> selectList(IPage<Class> page, @Param(Constants.WRAPPER)Wrapper<Class> Wrapper);
}